computed: {
type: {
get() {
return this.count > 10 ? "大" : "小"
},
set(newValue) {
if (newValue == "大") {
this.count = 11
}else {
this.count = 0
}
}
}
}
let instance = Vue.createApp(App).mount("#Application") //初始值為0
console.log(instance.count) //初始狀態為「小」
console.log(instance.type) //對計算屬性進行修改
instance.type = "大"
console.log(instance.count)
今天介紹的內容就先到這邊,明天將會介紹的是函數限流!